package com.example.demo.controlller;

import com.example.demo.pojo.PageBean;
import com.example.demo.pojo.Patientoutlist;
import com.example.demo.pojo.Result;
import com.example.demo.service.Patientoutservice;
//import net.minidev.json.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/patientoutlist")
public class Patientoutlistcontroller {
    @Autowired
    Patientoutservice patientoutservice;
    @RequestMapping("/queryAll")
    @ResponseBody
    //用于查询所有的患者出院清单信息并返回结果
    public Result queryAll(){
        List<Patientoutlist> list=patientoutservice.queryAll();
        return Result.success(list);

    }

    @RequestMapping("/delete")
    @ResponseBody
    public Result  deleteById(String pid){
        patientoutservice.deleteById(pid);
        return Result.success();
    }

    @RequestMapping("/queryName")
    @ResponseBody
    //根据患者姓名查询相应的患者出院清单信息并返回结果
    public  Result queryName(String name){
        List<Patientoutlist>list=patientoutservice.queryName(name);
        return Result.success(list);
    }

    @RequestMapping("/add")
    @ResponseBody
    public Result insert(@RequestBody Patientoutlist patientoutlist){
        patientoutservice.insert(patientoutlist);
        return Result.success();
    }

    @RequestMapping("/update")
    @ResponseBody
    public  Result   update(@RequestBody Patientoutlist patientoutlist) {
        patientoutservice.update(patientoutlist);
        return Result.success();
    }
    @RequestMapping("/page1")
    @ResponseBody
    public Result page(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean pageBean=patientoutservice.page(page,pageSize);
        return    Result.success(pageBean);
    }



}
